from common import KLineEnum
from common.utils import JsonUtil
from common.utils.StockPool import stock_pool
from service import KLineService


# 旭日东升：第一天大跌，次日开盘价高于第一天收盘价，次日收盘价高于第一天最高价
def invoke():
    for item in stock_pool:
        item_json = JsonUtil.info_to_json(item)
        k_lines = KLineService.day_k_size(item_json['code'], item_json['name'], 3)
        # print(k_lines)
        day0_k_info = KLineEnum.Stock.format_k_line(k_lines[0])
        day1_k_info = KLineEnum.Stock.format_k_line(k_lines[1])
        day2_k_info = KLineEnum.Stock.format_k_line(k_lines[2])
        # print(day0_k_info)
        # day0_sp = float(day0_k_info['sp'])
        # print(day0_sp)
        # day0_kp = float(day0_k_info['kp'])
        if float(day1_k_info['sp']) < float(day1_k_info['kp']):
            down = (float(day1_k_info['kp']) - float(day1_k_info['sp'])) / float(day1_k_info['sp'])
            # print(item_json['name']+'跌幅：-'+str(round(down, 4)*100))
            down = round(down, 4)
        else:
            continue
        if down > 0.03 and float(
                day2_k_info['sp']) > float(day2_k_info['kp']) > float(day1_k_info['max']):
            print('旭日东升出现=====》' + str(item_json))


if __name__ == '__main__':
    invoke()
